package com.necsv;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import android.app.TabActivity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.LinearLayout;
import android.widget.ViewAnimator;
import android.widget.TabHost.OnTabChangeListener;
import android.widget.TabHost.TabContentFactory;

public class TabHostActivity extends TabActivity implements 
	TabContentFactory, OnTabChangeListener{
	private static final String CATELOGY_ACT1 = TabHostActivity.class.getPackage().getName() + ".ACT1";
	private static final String TAG = "TabHostActivity";
	
	
	private static class ActivityItem{
		String id = null;
		Intent intent = null;
		boolean marked = false;
		boolean botab = false;
	}
	
	private static class TabItem{
		String tag = null;
		CharSequence label = null;
		Drawable icon = null;
		List <ActivityItem> activityList = new ArrayList<ActivityItem>();
	}
	
	public static class Holder{
		private final Map<String, TabItem>tabItemMap = new LinkedHashMap<String, TabHostActivity.TabItem>();
	}
	private final Map<String, ViewAnimator>tabContainerView = new HashMap<String, ViewAnimator>();
	
	private LinearLayout tabs = null;
	private Animation slideFromLeft = null;
	private Animation slideFromRight = null;
	private Animation slideToLeft = null;
	private Animation slideToRight = null;
	private Animation tabSlideToLeft = null;
	private Animation tabSlideToRight = null;
	
	private Holder getHolder(){
		return null; ///
	}
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO oncreate
		super.onCreate(savedInstanceState);
		Log.v(TAG, "category:" + CATELOGY_ACT1);
		slideFromLeft = AnimationUtils.loadAnimation(this,R.anim.slide_from_left_ );
		final Holder holder = getHolder();
		Bundle extras = getIntent().getExtras();
		holder.tabItemMap.isEmpty();
		Log.v(TAG, "Bundle>>");
//		if(holder.tabItemMap.isEmpty() || extras != null){
//			Log.v(TAG, "holder.tabItemMap.isEmpty()");
//			final PackageManager pm = getPackageManager();
//			Intent act1Intent = new Intent(Intent.ACTION_MAIN,null);
//			act1Intent.addCategory(CATELOGY_ACT1);
//			
//			List<ResolveInfo> list = pm.queryIntentActivities(act1Intent, 0);
//			for(ResolveInfo info : list){
//				TabItem tabItem = new TabItem();
//				tabItem.tag = info.activityInfo.name;
//				tabItem.label = info.loadLabel(pm);
//				tabItem.icon = info.activityInfo.loadIcon(pm);
//				
//				ActivityItem activityItem = new ActivityItem();
//				activityItem.id = tabItem.tag;
//				activityItem.intent = new Intent()
//					.setComponent(new ComponentName(
//							info.activityInfo.applicationInfo.packageName, 
//							info.activityInfo.name));
//				tabItem.activityList.add(activityItem);;
//				holder.tabItemMap.put(tabItem.tag, tabItem);
//			}
//		}
		setContentView(R.layout.simpletab);
		
	}
	public void onTabChanged(String tabId) {
		// TODO Auto-generated method stub
		
	}
	public View createTabContent(String tag) {
		// TODO Auto-generated method stub
		return null;
	}
	

}
